package com.ash.service.user;

import com.ash.domain.UserInfo;
import com.ash.mapper.user.UserInfoMapper;
import com.ash.mapper.user.UserMapper;
import com.ash.util.JsonUtil;
import com.ash.util.PojoUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author : Chen Chao
 * @encoding : UTF-8
 * @date : 2021/4/3 14:52
 * @file : project06.com.ash.service.user.UserInfoServiceImpl.java
 * @software : IntelliJ IDEA
 * @since : 1.8
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Resource
    UserInfoMapper userInfoMapper;
    @Override
    public UserInfo selectById(Integer uid) {
        return userInfoMapper.selectById(uid);
    }

    @Override
    public Integer update(UserInfo userInfo) {
        if(userInfo.getUid()==null){
            return 0;
        }
        return userInfoMapper.update(PojoUtil.beanToMap(userInfo).entrySet(),userInfo.getUid());
    }

    @Override
    public int add(UserInfo userInfo) {
        return userInfoMapper.add(userInfo);
    }

}
